package by.parfen.game.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Queue;

import by.parfen.game.datamodel.GamePlayer;
import by.parfen.game.datamodel.GameSession;
import by.parfen.game.datamodel.enums.GameState;
import by.parfen.game.service.GameSessionService;

public class GameSessionServiceImpl implements GameSessionService {

	@Override
	public GameSession create(String name) {
		GameSession gameSession = new GameSession(name);
		gameSession.setCreationDate(new Date());
		gameSession.setGameState(GameState.FINISH);
		return gameSession;
	}

	@Override
	public void delete(GameSession gameSession) {
		// TODO Auto-generated method stub

	}

	@Override
	public List<GamePlayer> getGamePlayers(GameSession gameSession) {
		Queue<GamePlayer> gamePlayers = gameSession.getGamePlayers();
		if (gamePlayers != null) {
			return new ArrayList<GamePlayer>(gameSession.getGamePlayers());
		} else {
			return null;
		}
	}

}
